import type { Request, ResponseToolkit } from "@hapi/hapi";
import Hapi from "@hapi/hapi";
import { Notes } from "../../model/index";

let route: Hapi.ServerRoute<Hapi.ReqRefDefaults> = {
  path: "/removeNote",
  method: "get",
  handler: async (r: any, h: ResponseToolkit) => {
    try {
      await Notes.deleteOne({ _id: r.query.id });
      return { code: 200, data: true, message: "删除成功" };
    } catch (err: any) {
      return err;
    }
  },
  options: {
    plugins: {
      "hapi-swagger": {
        security: [{ apiKey: [] }],
      },
    },
    tags: ["api"],
  },
};
export default route;
